package ar.com.indra.commons.transaction;

import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.support.DefaultTransactionStatus;
import javax.sql.DataSource;

public class EncuestaDataSourceTransactionManager extends DataSourceTransactionManager{

	private static final long serialVersionUID = -8662920686329214605L;
	
	
	private boolean commit;
	
	public EncuestaDataSourceTransactionManager() {
		super();
	}
	
	public EncuestaDataSourceTransactionManager(DataSource dataSource) {
		super(dataSource);
	}

	public void setCommit(boolean commit) {
		this.commit = commit;
	}

	public boolean getCommit() {
		return commit;
	}
	protected void doCommit(DefaultTransactionStatus status) {
		if (commit){
			super.doCommit(status);	
		} else {
			doRollback(status);
		}
		
	}

}
